<template>
  <div>
    <webHead />
    <div class="movie-grid">
      <div class="panel">
        <div class="panel-header">
          <span class="panel-title">
            <span
              class="textcolor_red"
            ><h2>正在热映（{{ movieList.length }}部）</h2></span>
          </span>
          <span class="panel-more">
            <a
              href="javascript:;"
              class="textcolor_red"
              data-act="all-playingMovie-click"
            >
              <span>全部</span>
            </a>
            <span class="panel-arrow panel-arrow-red" />
          </span>
        </div>
        <div class="panel-content">
          <dl class="movie-list">
            <dd v-for="(item, i) in movieList" :key="i">
              <div class="movie-item">
                <a href="javascript:;">
                  <div class="movie-poster">
                    <img class="movie-poster-img" :src="item.imageUrl" alt="">
                    <div class="movie-overlay movie-overlay-bg">
                      <div class="movie-info">
                        <div class="movie-title" :title="item.name">
                          {{ item.name }}
                        </div>
                      </div>
                    </div>
                  </div>
                </a>
                <div class="movie-detail movie-detail-strong movie-sale">
                  <a href="javascript:;" class="active">购 票</a>
                </div>
              </div>
            </dd>
          </dl>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import webHead from './components/head.vue'
import { mapGetters } from 'vuex'
export default {
  name: 'Web',
  components: {
    webHead
  },
  data() {
    return { movieList: [] }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  created() {
    this.getMovieList()
  },
  methods: {
    async getMovieList() {
      const movieArr = (await this.$localStorage.getItem('allMovies')) || []
      this.movieList = movieArr
      console.log(movieArr)
    },
    async logout() {
      debugger
      await this.$localStorage.removeItem('curUser')
      this.$router.push(`/login`)
    }
  }
}
</script>

<style lang="scss" scoped>
.movie-grid {
  padding-top: 120px;
  width: 1200px;
  margin: auto;
  .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
}
.movie-list {
  display: flex;
  flex-wrap: wrap;
  .movie-item {
    position: relative;
    border: 1px solid #efefef;
    margin: -1px;
    margin-bottom: 50px;
  }
  .movie-poster {
    position: relative;
    // &::after {
    //   content: "";
    //   width: 100%;
    //   height: 100%;
    //   background: #000;
    //   position: absolute;
    //   top: 0;
    //   left: 0;
    //   opacity: 0.2;
    // }
    img {
      width: 160px;
      height: 220px;
      object-fit: cover;
    }
  }
  .movie-overlay {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: url()
      repeat-x bottom;
  }
  .movie-info {
    position: absolute;
    bottom: 10px;
    width: 100%;
    padding: 0 10px;
    color: #fff;
  }
  .movie-detail {
    height: 39px;
    line-height: 39px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    &:hover {
      background: #ef4238;
      a {
        color: #fff;
      }
    }
    a {
      color: #ef4238;
      display: block;
      font-size: 14px;
    }
  }
}
</style>
